home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / prg_casm / snpd9611.zip / EXT_KEYS.C < prev    next >
C/C++ Source or Header  |  1996-11-24  |  2KB  |  68 lines

  1. .I 0 2
  2. /* +++Date last modified: 23-Nov-1996 */
  3.  
  4. .I 16 6
  5. **  The user is granted a free limited license to use this source file
  6. **  to create royalty-free programs, subject to the terms of the
  7. **  license restrictions specified in the LICENSE.MFL file.
  8. **
  9. **  Revisions:
  10. **  30-Mar-96  Ed Blackman  OS/2 mods
  11. .D 17 1
  12. .I 25 2
  13. #define USING_DOS 0     /* Set to 1 to call DOS instead of the BIOS     */
  14.  
  15. .I 28 10
  16. #ifdef __OS2__
  17.       extern KBDKEYINFO ki;         /* defined in ISSHIFT.C */
  18.       KBDINFO kb_state;
  19.  
  20.       kb_state = setkbmode();       /* Change keyboard to binary mode */
  21.       KbdCharIn(&ki, IO_WAIT, 0);   /* Get the key */
  22.       restkbmode(kb_state);         /* restore previous keyboard mode */
  23.  
  24.       key = (ki.chScan << 8) + ki.chChar;       /* format it into an int */
  25. #else                       /* assume DOS */
  26. .I 30 11
  27.  #if USING_DOS
  28.       regs.h.ah = 7;
  29.       intdos(®s, ®s);
  30.       key = regs.h.al;
  31.       if (0 == key)
  32.       {
  33.             regs.h.ah = 7;
  34.             intdos(®s, ®s);
  35.             key = (regs.h.al << 8);
  36.       }
  37.  #else
  38. .I 33 1
  39.  #endif
  40. .I 54 1
  41. #endif
  42. .I 65 25
  43. #ifdef __OS2__
  44. KBDINFO setkbmode(void)
  45. {
  46.     USHORT rc;
  47.     KBDINFO kb_state;
  48.  
  49.     kb_state.cb = sizeof(kb_state);
  50.     KbdGetStatus(&kb_state, 0);
  51.     kb_state.fsMask &= ~KEYBOARD_ASCII_MODE;
  52.     kb_state.fsMask |= KEYBOARD_BINARY_MODE;
  53.     rc = KbdSetStatus(&kb_state, 0);
  54.  
  55. /*  if(rc) printf("KbdSetStatus rc = %04x\n", rc);  */
  56.  
  57.     return kb_state;
  58. }
  59.  
  60. void restkbmode(KBDINFO kb_state)    /* restore keyboard mode */
  61. {
  62.     USHORT rc;
  63.  
  64.     rc = KbdSetStatus(&kb_state, 0);
  65. }
  66. #endif      /* !__OS2__ */
  67.  
  68.